﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.Events.InvokableCall`3
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;
using System.Reflection;

#nullable disable
namespace UnityEngine.Events
{
  internal class InvokableCall<T1, T2, T3> : BaseInvokableCall
  {
    protected event UnityAction<T1, T2, T3> Delegate;

    public InvokableCall(object target, MethodInfo theFunction)
      : base(target, theFunction)
    {
      this.Delegate = (UnityAction<T1, T2, T3>) System.Delegate.CreateDelegate(typeof (UnityAction<T1, T2, T3>), target, theFunction);
    }

    public InvokableCall(UnityAction<T1, T2, T3> action) => this.Delegate += action;

    public override void Invoke(object[] args)
    {
      if (args.Length != 3)
        throw new ArgumentException("Passed argument 'args' is invalid size. Expected size is 1");
      BaseInvokableCall.ThrowOnInvalidArg<T1>(args[0]);
      BaseInvokableCall.ThrowOnInvalidArg<T2>(args[1]);
      BaseInvokableCall.ThrowOnInvalidArg<T3>(args[2]);
      if (!BaseInvokableCall.AllowInvoke((System.Delegate) this.Delegate))
        return;
      this.Delegate((T1) args[0], (T2) args[1], (T3) args[2]);
    }

    public void Invoke(T1 args0, T2 args1, T3 args2)
    {
      if (!BaseInvokableCall.AllowInvoke((System.Delegate) this.Delegate))
        return;
      this.Delegate(args0, args1, args2);
    }

    public override bool Find(object targetObj, MethodInfo method)
    {
      return this.Delegate.Target == targetObj && this.Delegate.Method.Equals((object) method);
    }
  }
}
